/**

 */
@isTest(SeeAllData=true)
private class GroupsHelper_Test {

    static testMethod void myUnitTest() {
        //TestUtils.createUsers();

        //User ldc = [SELECT Id,Name FROM User WHERE Name = '用户1'];
        //User ldc2 = [SELECT Id,Name FROM User WHERE Name = '用户2'];

        Id ldcProfile = [Select Id From Profile Where Name like '%工程%' limit 1 ].Id;
        
        User ldc = new User( Alias = 'samLdc7', 
                         Email = 'ldc@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = 'samLdc', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile, 
                         Country = 'United States',
                         IsActive = true,
                         CompanyName='Y-MKSY',
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='总经办',
                         Timezonesidkey = 'America/Los_Angeles', 
                         Username = 'ldc@test.com.maike' );
        ldc.FederationIdentifier = '00tttt';
        ldc.EmployeeNumber = '002222';
        insert ldc;
        
        User ldc2 = new User( Alias = 'samLdc8', 
                         Email = 'ldc1@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = 'samLdc2', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile, 
                         Country = 'United States',
                         IsActive = true,
                         CompanyName='Y-MKSY',
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='总经办',
                         Timezonesidkey = 'America/Los_Angeles', 
                         Username = 'ldc2@test.com.maike' );
        ldc2.FederationIdentifier = '001111';
        ldc2.EmployeeNumber = '123456';

        insert ldc2;
        
        
        Account acc=new Account();
        acc.Name='Test1229J';
        insert acc;
        
        Case cas=new Case();
        cas.AccountId=acc.Id;
        insert cas;
        WorkOrder__c wo=new WorkOrder__c();
        wo.Case__c=cas.Id;
        wo.Account__c=acc.Id;
        wo.Status__c='处理中';
        insert wo;
        
        PageReference page = new PageReference('/apex/CreateWorkOrderTeam?wkid='+wo.Id);
        System.Test.setCurrentPage(page);
        GroupsHelper ipc = new GroupsHelper(new ApexPages.StandardController(wo));
        ipc.strjson='[{"username":"test123","userid":"' + ldc.Id + '"}]';
        ipc.cancel();
        ipc.save();

        // List<WorkOrderTeam__c> a=[select id, User__r.Name from WorkOrderTeam__c where WorkOrder__c = :wo.Id];

        // 更新
        WorkOrderTeam__c wot = [select Id from WorkOrderTeam__c where WorkOrder__c = :wo.Id];
        wot.User__c = ldc2.Id;
        update wot;

        // 删除
        delete wot;
    }
}